home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / timer / timerStubs.c < prev    next >
C/C++ Source or Header  |  1990-11-28  |  3KB  |  133 lines

  1. /* 
  2.  * timerStubs.c --
  3.  *
  4.  *      Stubs for Unix compatible system calls.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header$";
  18. #endif /* not lint */
  19.  
  20. #define MACH_UNIX_COMPAT
  21.  
  22. #include <sprite.h>
  23. #include <stdio.h>
  24. #include <status.h>
  25. #include <errno.h>
  26. #include <user/sys/types.h>
  27. #include <user/sys/time.h>
  28. #include <mach.h>
  29. #include <proc.h>
  30. #include <timer.h>
  31. #include <vm.h>
  32.  
  33. #ifndef Mach_SetErrno
  34. #define Mach_SetErrno(err)
  35. #endif
  36.  
  37. int debugTimerStubs;
  38.  
  39. int
  40. Timer_GettimeofdayStub(tp, tzpPtr)
  41.     struct timeval     *tp;
  42.     struct timezone     *tzpPtr;
  43. {
  44.     struct timezone    tzp;
  45.     int            localOffset;
  46.     Boolean        DST;    
  47.     ReturnStatus    status;
  48.     Time        curTime;
  49.  
  50.     if (debugTimerStubs) {
  51.     printf("Timer_GettimeofdayStub\n");
  52.     }
  53.     Timer_GetRealTimeOfDay(&curTime, &localOffset, &DST);
  54.  
  55.     status = Vm_CopyOut(sizeof(Time), (Address)&curTime, (Address)tp);
  56.     if (status == SUCCESS) {
  57.     if (tzpPtr != (struct timezone *) NULL) {
  58.         tzp.tz_minuteswest     = -localOffset;
  59.         tzp.tz_dsttime         = DST;
  60.         status = Vm_CopyOut(sizeof(struct timezone), (Address)&tzp,
  61.                         (Address)tzpPtr);
  62.     }
  63.     }
  64.     if (status != SUCCESS) {
  65.     Mach_SetErrno(Compat_MapCode(status));
  66.     return -1;
  67.     }
  68.     return 0;
  69. }
  70.  
  71. int
  72. Timer_SettimeofdayStub(tp, tzpPtr)
  73.     struct timeval *tp;
  74.     struct timezone *tzpPtr;
  75. {
  76.     ReturnStatus status;    /* result returned by Sys_SetTimeOfDay */
  77.     Time curTime;
  78.     struct timezone tzp;
  79.  
  80.  
  81.     if (debugTimerStubs) {
  82.     printf("Timer_SettimeofdayStub\n");
  83.     }
  84.     /*
  85.      * Unix negates the local offset from UTC to make it positive
  86.      * for locations west of the prime meridian. 
  87.      */
  88.  
  89.     if (tzpPtr == NULL) {
  90.     int localOffset;
  91.     Boolean DST;
  92.  
  93.     Timer_GetRealTimeOfDay(&curTime, &localOffset, &DST);
  94.     status = Vm_CopyIn(sizeof(Time), (Address)tp, (Address)&curTime);
  95.     if (status == SUCCESS) {
  96.         Timer_SetTimeOfDay(curTime, localOffset, DST);
  97.     }
  98.     } else if (tp == NULL) {
  99.     Timer_GetRealTimeOfDay(&curTime, (int *) NULL, (Boolean *) NULL);
  100.     status = Vm_CopyIn(sizeof(tzp), (Address)tzpPtr, (Address)&tzp);
  101.     if (status == SUCCESS) {
  102.         Timer_SetTimeOfDay(curTime, -(tzp.tz_minuteswest), tzp.tz_dsttime);
  103.     }
  104.     } else {
  105.     status = Vm_CopyIn(sizeof(Time), (Address)tp, (Address)&curTime);
  106.     if (status == SUCCESS) {
  107.         status = Vm_CopyIn(sizeof(tzp), (Address)tzpPtr, (Address)&tzp);
  108.         if (status == SUCCESS) {
  109.         Timer_SetTimeOfDay(curTime,
  110.                            -(tzp.tz_minuteswest), tzp.tz_dsttime);
  111.         }
  112.     }
  113.     }
  114.     if (status != SUCCESS) {
  115.     Mach_SetErrno(Compat_MapCode(status));
  116.     return -1;
  117.     }
  118.     return 0;
  119. }
  120.  
  121. /*ARGSUSED*/
  122. int
  123. Timer_AdjtimeStub(delta, olddelta)
  124.  
  125.     struct timeval    *delta;
  126.     struct timeval    *olddelta;
  127. {
  128.     printf("adjtime is not implemented\n");
  129.     Mach_SetErrno(EINVAL);
  130.     return -1;
  131. }
  132.  
  133.